//
//  WQStatustoolBarView.swift
//  WeiBo
//
//  Created by 张德华 on 7/24/16.
//  Copyright © 2016 ZhangDeHua. All rights reserved.
//

import UIKit

class WQStatustoolBarView: UIView {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = RandomColor()
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    
    var statusViewModel: WQStatusViewModel? {
        didSet{
            
            retweetButton.setTitle(statusViewModel?.repostsCountStr, forState: UIControlState.Normal)
            commentButton.setTitle(statusViewModel?.commentsCountStr, forState: UIControlState.Normal)
            unlikeButton.setTitle(statusViewModel?.attitudesCountStr, forState: UIControlState.Normal)
        }
    }
    
    
    
    func setupUI() {
        ///------ 添加控件
        addSubview(retweetButton)
        addSubview(commentButton)
        addSubview(unlikeButton)
        addSubview(line1)
        addSubview(line2)
        
        ///------ 约束
        retweetButton.snp_makeConstraints { (make) in
            make.leading.top.bottom.equalTo(self)
            make.width.equalTo(commentButton)
        }
        commentButton.snp_makeConstraints { (make) in
            make.leading.equalTo(retweetButton.snp_trailing)
            make.top.bottom.equalTo(self)
            make.width.equalTo(unlikeButton)
        }
        unlikeButton.snp_makeConstraints { (make) in
            make.leading.equalTo(commentButton.snp_trailing)
            make.trailing.top.bottom.equalTo(self)
        }
        line1.snp_makeConstraints { (make) in
            make.leading.equalTo(retweetButton.snp_trailing)
            make.centerY.equalTo(retweetButton)
        }
        line2.snp_makeConstraints { (make) in
            make.leading.equalTo(commentButton.snp_trailing)
            make.centerY.equalTo(commentButton)
        }
     
    }
    
    // MARK: - ************懒加载
    private lazy var retweetButton: UIButton = UIButton(wq_title: "转发", titleColor: UIColor.darkGrayColor(), imageName: "timeline_icon_retweet", backgroundImage: "timeline_card_bottom_background")
    private lazy var commentButton: UIButton = UIButton(wq_title: "评论", titleColor: UIColor.darkGrayColor(), imageName: "timeline_icon_comment", backgroundImage: "timeline_card_bottom_background")
    private lazy var unlikeButton: UIButton = UIButton(wq_title: "赞", titleColor: UIColor.darkGrayColor(), imageName: "timeline_icon_unlike", backgroundImage: "timeline_card_bottom_background")
    private lazy var line1: UIImageView = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
    private lazy var line2: UIImageView = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
    
    
}



